package com.hcr.kingdeeutil;

import com.google.gson.Gson;
import com.hcr.kingdeeutil.common.FOrgId;
import com.hcr.kingdeeutil.common.element.MarkFstaffNumber;
import com.hcr.kingdeeutil.common.element.MarkNumber;
import com.hcr.kingdeeutil.data.fhead.ProjectPaymentReceiptFBillHead;
import com.hcr.kingdeeutil.data.fhead.RepaymentSubscriptionFBillHead;
import com.hcr.kingdeeutil.result.kingdeeResult;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author songwei.zhang
 * @version 0.1.0
 * @Description
 * @create 2021-04-08 18:45
 **/
public class ProjectPayment {
    public static void main(String[] args) throws Exception {
        String POST_K3CloudURL = "http://192.168.15.88/K3Cloud/";
        String dbId = "6049900ae59f36";
        String uid = "demo";
        String pwd = "888888";
        int lang = 2052;
        String accessToken = KingdeeUtil.login(POST_K3CloudURL, dbId, uid, pwd, lang);
        if (StringUtils.isNotEmpty(accessToken)) {
            //项目回款认款单
            String sFormId = "kf358481f1cff4697ab844ffd21dc49b2";
            ProjectPaymentReceiptFBillHead projectPaymentReceiptFBillHead = new ProjectPaymentReceiptFBillHead();
            // 单据编号 必填
            projectPaymentReceiptFBillHead.setFBillNo("RK2021040801");
            //认款人
            MarkFstaffNumber markFstaffNumber = new MarkFstaffNumber();
            markFstaffNumber.setFSTAFFNUMBER("00195");
            projectPaymentReceiptFBillHead.setFProposerID(markFstaffNumber);
            //到款公司
            FOrgId markNumber = new FOrgId();
            markNumber.setFNumber("001");
            projectPaymentReceiptFBillHead.setF_SRUB_OrgId(markNumber);
            //客户名称
            MarkNumber customerNum = new MarkNumber();
            customerNum.setFNUMBER("CUST00001");
            projectPaymentReceiptFBillHead.setFcustomer(customerNum);
            //借款项目号
            MarkNumber markNumber1 = new MarkNumber();
            markNumber1.setFNUMBER("000194");
            projectPaymentReceiptFBillHead.setFProjectnumber(markNumber1);
            //借款合同号
            MarkNumber markNumber2 = new MarkNumber();
            markNumber2.setFNUMBER("000033");
            projectPaymentReceiptFBillHead.setFContractNo(markNumber2);

            //认款金额
            projectPaymentReceiptFBillHead.setFAmount(BigDecimal.valueOf(5000));
            //认款日期
            projectPaymentReceiptFBillHead.setFDate(new Date());
            //支付方式
            projectPaymentReceiptFBillHead.setFPaymentmethod("汇款");
            //回款号
            projectPaymentReceiptFBillHead.setFFcustomer("00000000000001");
            //币别 必填
            MarkNumber markNumber3 = new MarkNumber();
            markNumber3.setFNUMBER("PRE001");
            projectPaymentReceiptFBillHead.setFCurrencyID(markNumber3);
            //本位币 必填
            projectPaymentReceiptFBillHead.setFLocCurrencyID(markNumber3);
            //认款本位币
            projectPaymentReceiptFBillHead.setFAmountcurrency(BigDecimal.valueOf(5000));

            //银行账号
            MarkNumber markNumber4 = new MarkNumber();
            markNumber4.setFNUMBER("123");
            projectPaymentReceiptFBillHead.setFACCOUNTNAME(markNumber4);


            kingdeeResult result = KingdeeUtil.save(sFormId,projectPaymentReceiptFBillHead,accessToken);
            Gson gson = new Gson();
            System.out.println(gson.toJson(result));
        }
    }
}
